import java.io.BufferedReader;
import java.io.File;
import java.io.FileWriter;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;


public class CertificateImporter {

	private static String webaddress = "https://api.eveonline.com/eve/CertificateTree.xml.aspx";
	
	public void createXMLFile() throws Exception {
		URL url = new URL(webaddress);
		URLConnection con = url.openConnection();
		InputStreamReader reader = new InputStreamReader(con.getInputStream());
		BufferedReader bi = new BufferedReader(reader);
		StringBuffer output = new StringBuffer();
		
		
		String line;
		while ((line = bi.readLine()) != null) {
			output.append(line + '\n');
		}
		
		File file = new File("Data/certificates.xml");
		FileWriter writer = new FileWriter(file);
		writer.write(output.toString());
		writer.close();
	}
	
	public static void main(String[] args) throws Exception {
		CertificateImporter imp = new CertificateImporter();
		imp.createXMLFile();
	}

}
